



        var watchScrollTop = null;
        var scrollIntvl = null;
        var scrollNew = 0;
        var scrollOld = 0;
        var scrollStep = 20;
        var toTop = false;
        var scrollStart = false;

        //禁止滚动
        window.addEventListener('DOMMouseScroll', function (e) {
            if(!$('.mobileDevice').length && !preventScrl){
                if(e.detail > 0){//向下滚动
                    console.log('//向下滚动');
                    scrollDown = true;
                }else{//向上滚动
                    console.log('//向上滚动');
                    scrollDown = false;
                }
                custmzScroll();
            }
        })
        window.addEventListener('mousewheel', function (e) {
            if(!$('.mobileDevice').length && !preventScrl){
                if(e.wheelDelta < 0){//向下滚动
                    scrollDown = true;
                }else{//向上滚动
                    scrollDown = false;
                }
                custmzScroll();
            }
        })

        
        function custmzScroll(){
            var bodyH = $('body')[0].offsetHeight;
            var canScroll = parseInt(bodyH - window.innerHeight);
            if(scrollDown){
                scrollNew += 100;
                scrollNew > canScroll && (scrollNew = canScroll);
            }else{
                scrollNew -= 100;
                scrollNew < 0 && (scrollNew = 0);
            }
            
            scrollStart = true;
        }

        function scrlDown(){
            scrollStart = true;
            scrollNew = window.innerHeight;
        }

        function updateScroll(val){
            document.documentElement.scrollTop = document.body.scrollTop = val;
            $('.scroll .bar').addClass('appear');
            if(!val && toTop){
                console.log('at top');
                scrollStart = false;
                preventScrl = true;
                $('main .banner .ttls,.scroll').addClass('disappear');

                setTimeout(function(){
                    $('main .banner').addClass('disappear');
                    $('main .banner .inner').css('top',$('.projects .swiper .swiper-slide-active')[0].getBoundingClientRect().top + 'px');
                },500)
            }
        }

        watchScrollTop = setInterval(function(){
            var bodyH = $('body')[0].offsetHeight;
            var canScroll = parseInt(bodyH - window.innerHeight);
            var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
            var percent = scrollTop / canScroll;
            var barCanRoll = window.innerHeight - $('.scroll .bar').height();
            var topVal = percent * barCanRoll;
            $('.scroll .bar')[0].topVal = topVal;
            $('.scroll .bar')[0].style.transform = 'translateY(' + topVal + 'px)';
        },10)

        scrollIntvl = setInterval(function(){
            if(!scrollStart) return false;
            if(scrollNew > scrollOld){
                scrollOld += Math.ceil((scrollNew - scrollOld) / scrollStep);
            }else{
                scrollOld -= Math.ceil((scrollOld - scrollNew) / scrollStep);
            }
            updateScroll(scrollOld);
        },10)

        $('.scroll .bar').mousedown(function(se){
            $(this).attr('canmove','true');
            var sEvnt = se.event || window.event;
            var startY = sEvnt.clientY;
            var This = $(this);
            var eleY = This[0].topVal;
            $(document).mousemove(function(eve){
                if(This.attr('canmove') != 'true') return false;
                var oe = eve.event || window.event;
                var mouseY = oe.clientY;
                var topVal = eleY + (mouseY - startY);
                var eleH = This[0].offsetHeight;
                var bodyH = $('body')[0].offsetHeight;
                var canScroll = parseInt(bodyH - window.innerHeight);
                var barCanRoll = window.innerHeight - eleH;
                var percent = topVal / barCanRoll;
                if(percent < 0){
                    percent = 0;
                }else if(percent > 1){
                    percent = 1;
                }
                var val = parseInt(percent * canScroll);
                updateScroll(val);
                scrollNew = scrollOld = val;
            })
        })

        $(document).mouseup(function(){
            $('.scroll .bar').attr('canmove','false');
        })